package org.inspiration.dudu.web.controller.message;

import lombok.RequiredArgsConstructor;
import org.aspectj.bridge.Message;
import org.inspiration.dudu.common.pojo.Result;
import org.inspiration.dudu.message.model.vo.MessageVO;
import org.inspiration.dudu.web.annotation.Loggable;
import org.inspiration.dudu.web.service.message.MessageFacadeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@Loggable
@RequestMapping("/messages")
public class MessageController {

    private final MessageFacadeService messageFacadeService;

    @GetMapping
    public Result<List<MessageVO>> getRecentMessages(@RequestParam("fromUserId") Long fromUserId,
                                                     @RequestParam("toUserId") Long toUserId,
                                                     @RequestParam("pageNum") Integer pageNum,
                                                     @RequestParam("pageSize") Integer pageSize) {
        List<MessageVO> list = messageFacadeService.getRecentMessages(fromUserId, toUserId, pageNum, pageSize);
        return Result.success(list);
    }
}
